package com.hopes.bizz.protocol.hj212.server.handler;

import lombok.extern.slf4j.Slf4j;

/**
 * 数据解析线程
 */
@Slf4j
public class DataParseThread implements Runnable{
    //待处理数据
    private String data;
    //数据处理
    private DataHandlerChain dataHandlerChain;

    public DataParseThread(String data, DataHandlerChain dataHandlerChain) {
        this.data = data;
        this.dataHandlerChain = dataHandlerChain;
    }

    @Override
    public void run() {
        try {
            long start = System.currentTimeMillis();
            log.debug("处理数据. data={}", data);
            dataHandlerChain.startHandler(data);
            long time =  System.currentTimeMillis()- start;
            log.debug("耗时(毫秒)：{}", time);
        } catch (Exception e) {
            log.error("数据处理出错", e);
        }
    }
}
